﻿Public Class Layer1

    Private _workspace As Workspace
    Private _layerName As String

    Property layerName() As String
        Get
            Return _layerName
        End Get
        Set(ByVal value As String)
            LayName.Text = value
            _layerName = value
        End Set
    End Property

    Property workspace() As Workspace
        Get
            Return _workspace
        End Get
        Set(ByVal value As Workspace)
            If value IsNot Nothing Then
                drawBox.Visible = True
            Else
                drawBox.Visible = False
            End If
            _workspace = value
        End Set
    End Property

    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        If workspace IsNot Nothing Then
            workspace.activateDrawing()
        End If
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        If workspace IsNot Nothing Then
            workspace.cancelDrawing()
        End If
    End Sub

    Private Sub btnConfirm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConfirm.Click
        If workspace IsNot Nothing Then
            OID.Text = workspace.validateDrawing()
        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If oidValue.Text Is Nothing Or String.IsNullOrEmpty(oidValue.Text) Then
            Return
        End If
        oidList.Items().Add(oidValue.Text)
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        If oidList.SelectedItem IsNot Nothing Then
            oidList.Items().Remove(oidList.SelectedItem)
        End If

    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        oidList.Items().Clear()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim listOid As List(Of String) = New List(Of String)
        For Each node As String In oidList.Items()
            listOid.Add(node)
        Next
        _workspace.deleteNodes(_layerName, listOid)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim listOid As List(Of String) = New List(Of String)
        For Each node As String In oidList.Items()
            listOid.Add(node)
        Next
        _workspace.highlightNodes(_layerName, listOid)
    End Sub
End Class